/*****************************************************************
 MYD Engine v0.1

 File: myd_importer.h
 Created: 02/07/09
*****************************************************************/

#ifndef MYD_IMPORTER_H
#define MYD_IMPORTER_H

#include "system/myd_system.h"
#include "entities/myd_sprite.h"
#include "myd_parser.h"
#include "tilemaps/CAmeFormat.h"
#include "tilemaps/myd_tilemap.h"
#include "3Dentities/myd_mesh3d.h"

namespace myd
{
	class MYD_API Importer
	{
		public:
			friend class Game;

			//destructor
			~Importer(void);

			//entry point
			bool importMap (const char* fileName);

		// resources accessors
		public:
			bool createSprite (const char* name, Sprite& tm_Sprite);
			Texture::Ptr getTexture (const char* fileName);

			//maps
			Tilemap* createSpriteMap(char* fileName, int startingX, int startingY);
			Tilemap* createTrueMap(char* fileName);
			ameHeader ameThing;

			bool importXFile(char* filename, Mesh3d &tm_mesh3d, LPDIRECT3DDEVICE9 tm_device);

		private:
			//constructor
			Importer(Renderer *tm_Renderer);

			//resources
			Renderer *wn_Renderer;

			std::map<std::string, Sprite*> spritesMap;
			std::map<std::string, Texture::Ptr> texturesMap;

			Sprite* m_pkCurrentSprite;

		//MY OWN SHIT
		public:
			Sprite* createSpriteFromFile(const char* name, int xoff, int yoff, 
									     int width, int height, unsigned long colorKey);
			Texture::Ptr importTextureFromFile(const char* name, unsigned long colorKey);
			
	};
}// end namespace
#endif //MYD_IMPORTER_H